//------------Sonic CD Flip Door Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 48: TYPE_FLIPDOOR


sub ObjectPlayerInteraction
	if Object.PropertyValue==0
		PlayerObjectCollision(C_PLATFORM,-24,-4,24,32)
		PlayerObjectCollision(C_TOUCH,-24,-8,24,8)
		if CheckResult==1
			if Player.YPos>Object.YPos
				if Object.Value0==0
					PlayStageSfx(4,0)
				endif
				Object.Value0=10
			endif
		endif
	else
		if Player.XPos<Object.XPos
			PlayerObjectCollision(C_TOUCH,-16,-24,0,24)
			if CheckResult==1
				if Object.Value0==0
					PlayStageSfx(4,0)
				endif
				Object.Value0=10
			endif
		else
			if Object.Value0==0
				PlayerObjectCollision(C_BOX,-24,-24,4,24)
			endif
		endif
	endif
endsub


sub ObjectDraw
	if Object.PropertyValue==0
		if Object.Value0>0
			DrawSprite(1)
			Object.Value0--
		else
			DrawSprite(0)
		endif
	else
		if Object.Value0>0
			DrawSprite(3)
			Object.Value0--
		else
			DrawSprite(2)
		endif
	endif
endsub


sub ObjectStartup
	LoadSpriteSheet("R1/Objects.gif")
	SpriteFrame(-24,-4,48,8,117,34)
	SpriteFrame(-24,-44,8,48,167,43)
	SpriteFrame(-4,-24,8,48,176,43)
	SpriteFrame(-4,-24,48,8,117,34)
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[FlipDoor]
			Object[ArrayPos0].DrawOrder=5
		endif
		ArrayPos0++
	loop
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
